import * as THREE from 'three'

export default class Base {
    constructor(canvas) {
        //设置场景
        this.scene = new THREE.Scene();
        //设置相机
        this.camera = new THREE.PerspectiveCamera(
            75,
            window.innerWidth / window.innerHeight,
            0.001,
            10000)
        //创建渲染器
        this.renderer = new THREE.WebGLRenderer({
            canvas,
            antialias: true,//抗锯齿
        })
        this.camera.position.y = 0.8
        this.camera.position.z = 4.5
        this.camera.updateProjectionMatrix()//更新相机矩阵
        //设置渲染器大小
        this.renderer.setSize(window.innerWidth, window.innerHeight)
        //设置渲染器像素比
        this.renderer.setPixelRatio(window.devicePixelRatio)
        //将render设置为可以投射阴影
        this.renderer.shadowMap.enabled = true
    }
    // update() {
    //     requestAnimationFrame(this.update.bind(this))
    //     this.renderer.render(this.scene, this.camera)
    // }
}